#!/bin/sh

#
# Test that including files works
#

. "$(cd "$(dirname "$0")" && pwd)/common.sh"

cat >$CONFIG.1 <<EOF
file-resource file {
        host-path = "${TESTFILE_150K}"
}
EOF
cat >$CONFIG.2 <<EOF
include("$CONFIG.1")
EOF
cat >$CONFIG.3 <<EOF
task complete {
	on-resource file { raw_write(0) }
}
EOF

cat >$CONFIG <<EOF
include($CONFIG.2)
include($CONFIG.3)
EOF

# Create the firmware file, then "burn it"
$FWUP_CREATE -c -f $CONFIG -o $FWFILE
$FWUP_APPLY -a -d $IMGFILE -i $FWFILE -t complete

# Check that the test file made it
cmp_bytes 150000 $TESTFILE_150K $IMGFILE

# Check that the verify logic works on this file
$FWUP_VERIFY -V -i $FWFILE
